"""#import tkinter as tk
import tkinter 
root=tkinter.Tk()   #Tk指窗口类
root.title("计算器")
root.geometry("300x400")
root.mainloop """

from tkinter import *
root=Tk()
root.title("计算器")
root.geometry("300x400")
lab1=Label(root,text="输入数据值")
lab1.grid(row=1,column=1)
x=StringVar()
eCount=Entry(root,width=20,textvariable=x)
eCount.grid(row=1,column=2)

btn=Button(root,text="1")
btn.grid(row=2,column=1)
btn=[None]*10
def click(Event):
    num=Event.widget["text"]
    x.set(x.get()+num)
#    x.set(str(e.x))
#    x.set(bin["text"])
#btn.bind("<Button-1>",click)
#root.bind("<Motion>",click)
for i in range(0,10):
    btn[i]=Button(root,text=str(i))
    btn[i].grid(row=2+int(i/3),column=i%3)
    btn[i].bind("Button-1>",lambda x:click(i))
root.mainloop()